package cn.itcast.mq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/*
 *采用简单方式时，不能自动新建队列，要在这个文件中新建
 *@Author Mister
 *@Date 2025/1/5 10:48
 */
@Configuration
public class  RabbitConfig {
    @Bean
    public Queue simpleQueue(){
        return new Queue("simple.queue",true);
    }
    @Bean
    public Queue workQueue(){
        return new Queue("work.queue",true);
    }
    @Bean
    public Queue fanoutQueue1(){
        return new Queue("fanout.queue1",true);
    }
    @Bean
    public Queue fanoutQueue2(){
        return new Queue("fanout.queue2",true);
    }

  @Bean
    public FanoutExchange fanoutExchange(){
      return new FanoutExchange("itcast.fanout");
    }
    @Bean
    public Binding bindFanout1(){
        return BindingBuilder.bind(fanoutQueue1()).to(fanoutExchange());
    }
    @Bean
    public Binding bindFanout2(){
        return BindingBuilder.bind(fanoutQueue2()).to(fanoutExchange());
    }


}

